package moodish.client.gui.listener;

import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import moodish.client.gui.MainPanel;

public class MoodSentinel implements MouseListener, ComponentListener {
	
	private MainPanel panel;
	
	public MoodSentinel(MainPanel panel){
		this.panel = panel;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		select(e.getComponent().getName());
	}

	@Override
	public void mouseEntered(MouseEvent e) {}

	@Override
	public void mouseExited(MouseEvent e) {}

	@Override
	public void mousePressed(MouseEvent e) {
		select(e.getComponent().getName());
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		select(e.getComponent().getName());
	}
	
	
	public void select(String componentName){
		panel.updateSelected("./resources/emotions/"+componentName);
	}

	@Override
	public void componentHidden(ComponentEvent e) {
		e.getComponent().validate();
		e.getComponent().repaint();
	}

	@Override
	public void componentMoved(ComponentEvent e) {
		e.getComponent().validate();
		e.getComponent().repaint();
	}

	@Override
	public void componentResized(ComponentEvent e) {
		e.getComponent().validate();
		e.getComponent().repaint();
	}

	@Override
	public void componentShown(ComponentEvent e) {
		e.getComponent().validate();
		e.getComponent().repaint();
	}

}
